﻿using douban.Core.ViewModels;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

namespace douban.app.Views
{
    public class PageBase : Page
    {
        protected VmBase Vm;

        public PageBase()
        {
            this.NavigationCacheMode = NavigationCacheMode.Enabled;
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Vm = (VmBase)DataContext;
            Vm?.OnNavigatedTo(e);
        }

        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);
            Vm?.OnNavigatedFrom(e);
        }
    }
}
